package service

import (
	"context"
	"github.com/cloudwego/hertz/pkg/app"
	"github.com/jinzhu/copier"
	stage "stage/hertz_gen/stage"
	"stageRpc/client"
	stageRpcModel "stageRpc/kitex_gen/stage"
)

type GetFloorInfoService struct {
	RequestContext *app.RequestContext
	Context        context.Context
}

func NewGetFloorInfoService(Context context.Context, RequestContext *app.RequestContext) *GetFloorInfoService {
	return &GetFloorInfoService{RequestContext: RequestContext, Context: Context}
}

func (h *GetFloorInfoService) Run(req *stage.Floor) (resp *stage.Floor, err error) {
	// 通过id或者name获取信息
	var floor = &stageRpcModel.Floor{}
	r, err := client.StageClient.GetFloorInfo(h.Context, floor)
	if err != nil {
		return nil, err
	}
	resp = new(stage.Floor)
	if err = copier.Copy(resp, r); err != nil {
		return nil, err
	}
	return
}
